package com.ymatou.img.api.service;

import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
 * 上传图片Call FreeMaker Template自动生成代码
 */
public class UploadImageCall extends YmatouBaseCall {
	private static String opurl = "api/Image/Upload";

	public UploadImageCall() {
		super(EnvSetup.getSystemUrl("api_img"), opurl, "FILE", "PARAM");
	}

	// 上传文件不能加默认头信息
	@Override
	public void addDefHeader() {
	}

	/**
	 * 获取图片地址
	 * 
	 * @return
	 */
	public String getPicUrl() {
		String url = null;
		JSONObject Data = null;
		try {
			Data = new JSONObject(getReturnData()).getJSONObject("Result");
			url = Data.getString("PicUrl");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return url;
	}

	/**
	 * 获取Status
	 * 
	 * @return
	 */
	public String getStatus() {
		String Status = null;
		try {
			Status = new JSONObject(getReturnData()).getString("Status");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Status;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String Msg = null;
		try {
			Msg = new JSONObject(getReturnData()).getString("Msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Msg;
	}
}